/*
 * Serum
 *
 * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
 */

Ext.namespace('Serum.Exception.Handler', 'Serum.Exception.Handler.Error');

Serum.Exception.Handler.process = function(error) {
    Serum.App.get().eventListener.fireEvent(error);
};

Serum.Exception.Handler.Error.session = function() {
    window.location.reload(true);
};

Serum.Exception.Handler.Error.permissiondenied = function() {
    Serum.Selector.get().set({ module: 'Core', controller: 'Index', action: 'index' });
};

Serum.Exception.Handler.Error.unknown = function() {
    // Checks if session is expired
    Serum.Ajax.request({
            scope:       this,
            params:      {
                            method:         Serum.Selector.get().method({
                                                                            module:         'Admins',
                                                                            controller:     'Logon',
                                                                            action:         'check'
                                                                        }),
                            requestId:      Serum.Helper.Request.id(),
                            currentModule:  Serum.Selector.get().module
                        },
            onSuccess:  function(response) {
                            window.alert(__('base~internal_error'));
                       }
        });
};